package com.health.system.service.system.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.health.system.model.system.Role;

import cn.org.rapid_framework.page.Page;
import cn.org.rapid_framework.page.PageRequest;
import com.health.system.javacommon.base.*;

import com.health.system.model.system.*;
import com.health.system.dao.system.*;
import com.health.system.service.system.impl.*;
import com.health.system.service.system.*;

@Component("permissionManager")
@Transactional
public class PermissionManagerImpl extends BaseManager<Permission,java.lang.String> 
					implements PermissionManager {

	private PermissionDao permissionDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性*/
	public void setPermissionDao(PermissionDao dao) {
		this.permissionDao = dao;
	}
	public EntityDao getEntityDao() {
		return this.permissionDao;
	}
	
	@Transactional(readOnly=true)
	public Page findByPageRequest(PageRequest pr) {
		return permissionDao.findByPageRequest(pr);
	}
	
	public Boolean  removeByIdArry(Permission u) {
		Boolean result =false;
		int i =-1,size=u.getIdList().size();
		i =permissionDao.removeByIdArry(u);
		if(i==size){
			result =true;
		}else{
			throw new RuntimeException();
		}
		return result;
	}
	
	/**
	 * bzq add 2010-05-28
	 */
	public Page pageNewSelect(PageRequest pr) {
		return permissionDao.pageNewSelect(pr);
	}

	public List getAllByType(String type) {
		List list = permissionDao.getAllByType(type);
		return list;
	}

	public List selectPermissionMenuAndAction() {
		if(null==permissionDao){
			System.out.println("## PermissionDao is null");
		}
		List list = permissionDao.selectPermissionMenuAndAction();
		return list;
	}

	public List getPermissionByUserId(String userId) {
		List list = permissionDao.getPermissionByUserId(userId);
		return list;
	}

	public void permissionDelete(java.lang.String id) {
		removeById(id);
		permissionDao.deleteRolePermission(id);
	}

	public List getListByMap(Map map) {
		return permissionDao.getListByMap(map);
	}
	
	public List getPermissionByName(String name){
		return permissionDao.getPermissionByName(name);
	}
	
}
